﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SyncLib.Interface;
using System.Configuration;
using System.Windows.Forms;
using SyncLib.Provider.UrlEditor;

namespace SyncLib.Provider
{
    public class StaticUrlProvider : IUrlProvider
    {
        public StaticUrlProvider()
        {
            _Editor = new StaticUrlEditor();
            _Editor.txtUrl.Text = Url;
        }
        #region IUrlProvider Members

        public Uri CreateUri()
        {
            return new Uri(ConfigurationManager.AppSettings["StaticUri"]);
        }
        public string Url
        {
            get
            {
                return ConfigurationManager.AppSettings["StaticUri"];
            }
        }
        public string BindingName
        {
            get
            {
                return "WSHttpBinding_ISyncManager";
            }
        }
        StaticUrlEditor _Editor; 
        public UserControl Editor {
            get { return _Editor; }
        }
        public void Save()
        {
            ConfigurationManager.AppSettings["StaticUri"] = _Editor.txtUrl.Text;
            ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None).Save();
        }
        #endregion
    }
    public class DynmicUrlProvider : IUrlProvider
    {

        #region IUrlProvider Members
        public Uri CreateUri()
        {
            return new Uri(ConfigurationManager.AppSettings["StaticUri"]);
        }
        public string Url
        {
            get
            {
                return ConfigurationManager.AppSettings["StaticUri"];
            }
        }
        public string BindingName
        {
            get
            {
                return "WSHttpBinding_ISyncManager";
            }
        }
        public UserControl Editor { get; set; }
        public void Save()
        {
        }
        #endregion
    }
}
